<!DOCTYPE HTML>
<html>
<meta charset="utf-8"/>
    <head>
        <title>注册</title>
 <script type="text/javascript">
	var re = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/; 
	function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
    return currentdate;
} 

    function checkForm(form){
	if(form.password1.value!=form.password2.value){
     alert("different!write your password again");
      //return false;
	  }else 
	  if(form.password1.value.length<8)
	{alert("your password is too short!");
	//return false;
	}else 
    if (re.test(document.getElementById("user_email").value))
	{return storage();
	//return false;
	}
	else alert("wrong formatting of E-mail");}
	
	function storage(){if(!window.localStorage){
            alert("localstorage don't support");
            return false;
        }else var i=(localStorage.length/5);
		if(i==0)
		    {
		   localStorage.setItem(i+1,document.getElementById("user_name1").value);
		   localStorage.setItem("password"+(i+1),document.getElementById("password1").value);
		   localStorage.setItem("email"+(i+1),document.getElementById("user_email").value);
		   var data1=getNowFormatDate();
		   localStorage.setItem("registertime"+(i+1),data1);
		   localStorage.setItem(document.getElementById("user_name1").value+"_log_time",null);
		   window.location.href='https://siriuspotter.gitee.io/sign_in/';
		   return true;
		   }
		   
		  else {
		  for(var k=0;k<localStorage.length;k++)
		   {if(localStorage.getItem(localStorage.key(k))!=document.getElementById("user_name1").value)
		     continue;
		    
			else {alert("username exists");return false;}}
		   {
		   localStorage.setItem(i+1,document.getElementById("user_name1").value);
		   localStorage.setItem("password"+(i+1),document.getElementById("password1").value);
		   localStorage.setItem("email"+(i+1),document.getElementById("user_email").value);
		    var data1=getNowFormatDate();
		   localStorage.setItem("registertime"+(i+1),data1);
		   localStorage.setItem(document.getElementById("user_name1").value+"_log_time",null);
		   window.location.href='https://siriuspotter.gitee.io/sign_in/';
		   return true;
		   }
		}	}
		//if(localStorage.hasOwnProperty("document.getElementById("user_name1").value"))
		//alert("user_name1 is used");
		
   </script>
		<style>
		.h{text-align:center;}
		.form {
       margin: auto;
       width: 300px;
       border: 3px solid #73AD21;
       padding: 20px;} 
	   .p{font-size:10px;}
	   .input{height:30px;}
     </style>
    </head>
    <body >
	<h1 class=h>register your account</h1>
	<div class="form">
	
        <form name="usersform" method="post" onsubmit="return checkForm(this)" >
            <input class="input" type="text" name="user_name1" id="user_name1" placeholder="your first name" maxlength="13" size="35"required="required"> 
			<br><br>
            <input class="input" type="password" name="password1" id="password1" placeholder="your password"maxlength="25" size="35"required="required">
			<br><br>
			<input class="input" type="password" name="password2" id="password2" placeholder="please ensure your password" maxlength="25" size="35"required="required">
			<br><br>
            <input class="input" type="email" name="user_email" id="user_email" placeholder="your eamil address" size="35"required="required"/>
			<p><input type="submit" name="sign in" value="submit"></p>
</div>
        </form>
    </body>
</html>